package com.rh.bmw4s.fragment;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.rh.bmw4s.R;
import com.rh.bmw4s.comm.ConfigValue;
import com.rh.bmw4s.ui.SearchActivity;
import com.rh.bmw4s.ui.WantToBuyActivity;
import com.rh.bmw4s.ui.WantToSellActivity;
import com.rh.bmw4s.utills.SPUtils;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import butterknife.Unbinder;

/**
 * Created by Administrator on 2017/9/27.
 */

public class ThreeFragment extends Fragment {

    @BindView(R.id.title_left_one_btn)
    ImageView titleLeftOneBtn;
    @BindView(R.id.tv_middle_title)
    TextView tvMiddleTitle;
    @BindView(R.id.title_right_one_btn)
    ImageView titleRightOneBtn;
    @BindView(R.id.rl_buy)
    RelativeLayout rlBuy;
    @BindView(R.id.rl_sell)
    RelativeLayout rlSell;
    Unbinder unbinder;
    private int anInt;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_3, container, false);
        unbinder = ButterKnife.bind(this, view);
        initView();
        return view;
    }

    private void initView() {
//        titleLeftOneBtn.setVisibility(View.VISIBLE);
        tvMiddleTitle.setText("二手车");
        titleRightOneBtn.setVisibility(View.VISIBLE);
        anInt = SPUtils.getInstance().getInt(ConfigValue.userId);
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        unbinder.unbind();
    }

    @OnClick({R.id.title_left_one_btn, R.id.title_right_one_btn, R.id.rl_buy, R.id.rl_sell})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.title_left_one_btn:
                break;
            case R.id.title_right_one_btn:
                Intent intent = new Intent(getActivity(), SearchActivity.class);
                intent.putExtra("searchtype", 1);
                startActivity(intent);
                break;
            case R.id.rl_buy:
                startActivity(new Intent(getActivity(), WantToBuyActivity.class));
                break;
            case R.id.rl_sell:
                startActivity(new Intent(getActivity(), WantToSellActivity.class));
//                Intent intent1 = new Intent(getActivity(), WebShowActivity.class);
//                intent1.putExtra("url", "http://4s.liexianghudong.com/index.php/home/index/sale/id/" + anInt);
//                getActivity().startActivity(intent1);
                break;
        }
    }
}
